<?php

/**
 * This is the model class for table "photos_like".
 *
 * The followings are the available columns in table 'photos_like':
 * @property integer $user_id
 * @property integer $photos_id
 * @property string $like
 * @property integer $draft_like
 * @property integer $primary_photos
 * @property integer $viewed
 * @property string $text
 */
class mPhotosLike extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return mPhotosLike the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'photos_like';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('user_id, photos_id, like, draft_like, primary_photos, viewed', 'required'),
			array('user_id, photos_id, draft_like, primary_photos, viewed', 'numerical', 'integerOnly'=>true),
			array('like', 'length', 'max'=>5),
			array('text', 'length', 'max'=>500),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('user_id, photos_id, like, draft_like, primary_photos, viewed, text', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'user_id' => 'User',
			'photos_id' => 'Photos',
			'like' => 'Like',
			'draft_like' => 'Draft Like',
			'primary_photos' => 'Primary Photos',
			'viewed' => 'Viewed',
			'text' => 'Text',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('user_id',$this->user_id);
		$criteria->compare('photos_id',$this->photos_id);
		$criteria->compare('like',$this->like,true);
		$criteria->compare('draft_like',$this->draft_like);
		$criteria->compare('primary_photos',$this->primary_photos);
		$criteria->compare('viewed',$this->viewed);
		$criteria->compare('text',$this->text,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}